package com.fen.testdemo.thread.chi;

import java.util.concurrent.*;

public class MyThreadPool {

    /**
     * 基本参数
     */
    static int corePoolSize = 10;

    static int maximumPoolSizeSize = 100;

    static long keepAliveTime = 1;

    static ArrayBlockingQueue workQueue = new ArrayBlockingQueue(10);


    public static void main(String[] args) {

        // 使用默认饱和策略创建线程池
        ThreadPoolExecutor executor = new ThreadPoolExecutor(
                corePoolSize,
                maximumPoolSizeSize,
                keepAliveTime,
                TimeUnit.SECONDS,
                workQueue
                // JDK1.8后此方法作废
        );
        // 向线程池中添加任务
        executor.execute(() -> System.out.println("ok"));
    }
}